<!-- 扫描图标 -->
<template lang="pug">
img(src="img/scan.svg" @click="scan" :height="height")
</template>

<script>
/*
  事件
    scan     扫描
*/

export default {
  name: "Scan",
  props: {
    // 高度
    height: {
      type: String,
      default: "30",
    },
  },
  data() {
    return {
    }
  },
  methods: {
    scan() {
      let onSuccess = (result) => {
        this.$emit("scan", result.text)
      }

      let onError = (error) => {
        console.log("scan failed: ${error}")
      }

      let option = {
        disableSuccessBeep: true,
      }

      cordova.plugins.barcodeScanner.scan(onSuccess, onError, option)
    },
  },
}
</script>

<style lang="stylus" scoped>

.c-root
  margin-left: 1rem

</style>
